/**
 * @file   MzSequenceFileReader.java
 * @author Wu Jian <wujian@miaozhen.com>
 * @date   Mon Apr 22 18:02:16 2013
 *
 * @brief  Test reader for MzSequenceFile
 *
 *
 */

package com.supertool.tong.merger.util;

import java.io.*;
import java.util.*;
import java.lang.System;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import com.supertool.tong.merger.util.MzSequenceFile;

import org.apache.hadoop.io.Text;
import org.apache.hadoop.io.compress.*;
import org.apache.hadoop.conf.*;
import org.apache.hadoop.fs.*;

public class MzSequenceFileReader {
    public static void main(String[] args) throws Exception {
        if (args.length > 2) {
            System.out.println("Usage: MzSequenceFileReader path meta");
            System.exit(2);
        }
        Configuration conf = new Configuration();
        FileSystem fs = FileSystem.get(conf);
        Path input = new Path(args[0]);
        String meta;
        if (args.length == 2) {
            meta = args[1];
        } else {
            meta = null;
        }

        MzSequenceFile.Reader reader =
                new MzSequenceFile.Reader(fs.open(input),
                        fs.getFileStatus(input).getLen(),
                        conf, meta);
        Text val = new Text();
        while (reader.next(val)) {
            System.out.println(val);
        }
    }
}
